<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>

</head>
<body>
<div style="background-color: #2ca02c">
    @if(count($errors)>0)
        @if(is_object($errors))
            @foreach($errors->all() as $error)
                <p>{{$error }}</p>
            @endforeach
        @else
            {{$errors}}
        @endif

    @endif
</div>
<div style="text-align: center">
    <h1>祝孟港的管理系统</h1>
</div>

<form method="post">
    <div style="padding-left: 100px;padding-bottom: 20px">
        <h2>快捷导航</h2>
        <a href="{{url('Admin/index/create')}}">添加</a>
        <a href="{{url('Admin/index')}}">更新</a>
    </div>

    <table border="1px" width="80%"style="padding-left: 20px;color: red">
        <tr>
            <th width="1%">排序</th>
            <th width="5%">ID</th>
            <th width="5%">分类名称</th>
            <th width="5%">标题</th>
            <th width="5%">查看次数</th>
            <th width="5%">操作</th>


        </tr>

        @foreach($treeresoult as $y)
            <tr>
                <td class="tc">
                    <input type="text" name="ord[]" onchange="order(this,{{$y->cate_id}})" value="{{$y->cate_order}}" />
                </td>
                <td>{{$y->cate_id}}</td>
                <td>{{$y->cate_name}}</td>
                <td>{{$y->cate_title}}</td>
                <td>{{$y->cate_view}}</td>
                <td>&nbsp;<a href="{{url('Admin/index/'.$y->cate_id.'/edit')}}">修改</a>&nbsp;&nbsp;
                    <a href="javascript::" onclick="ti({{$y->cate_id}})">删除</a></td>
            </tr>
        @endforeach


    </table>

</form>
<script type="text/javascript" src="{{asset('resources/views/Admin/js/jquery-3.1.1.min.js')}}">
</script>
<script type="text/javascript" src="{{asset('resources/views/org/layer/layer.js')}}">
</script>

<script>
    function order(obj,cate_id ){
        var cate_order=$(obj).val();
        $.post("{{url('Admin/cate/changeorder')}}",{'_token':'{{csrf_token()}}','order':cate_order,'cateorder_id':cate_id},function (date) {

            if (date.status==1){
                location.href=location.href;
                layer.alert(date.msg, {icon: 6});
            }else {
                layer.msg(date.msg, {icon: 5});
            }
        });
    }
    function ti(cate_id){
        layer.confirm('你确定删除？', {
            btn: ['是的','取消'] //按钮
        }, function(){
            $.post("{{url('Admin/index/')}}/"+cate_id,{'_method':'delete','_token':'{{csrf_token()}}'},function (update) {
                     if(update.status==1){
                         location.href=location.href;
                         layer.alert(update.msg, {icon: 6});
                     }else {
                         layer.msg(update.msg, {icon: 5});
                     }
            });


        }, function(){

        });
    }
</script>
</body>
</html>